import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

/**
 * 重写路由的push方法
 */
const routerPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
    return routerPush.call(this, location).catch(error=> error)
};

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'home',
        component: Home,
    },
    {
        path: '/search',
        name: 'search',
        component: () => import('../views/search.vue')
    },
    {
        path: '/test',
        name: 'test',
        component: () => import('../views/test.vue')
    }
    // {
    //     path: '/',
    //     name: 'home',
    //     component: Home,
    //     children: [
    //         {
    //             path: 'message',
    //             name: 'message',
    //             component: () => import('../views/message/index.vue')
    //         },
    //         {
    //             path: 'friends',
    //             name: 'friends',
    //             component: () => import('../views/friend/index.vue')
    //         },
    //         {
    //             path: 'setting',
    //             name: 'setting',
    //             component: () => import('../views/setting.vue')
    //         }
    //     ]
    // },
    // Friend
    // {
    //     path: '/search-friends',
    //     name: 'searchFriends',
    //     component: () => import('../views/friend/searchFriends.vue')
    // },
    // {
    //     path: '/friends-request',
    //     name: 'friendRequest',
    //     component: () => import('../views/friend/friendRequest.vue')
    // },
    // // Message
    // {
    //     path: '/message-detail',
    //     name: 'messageDetail',
    //     component: () => import('../views/message/messageDetail.vue')
    // },
    // {
    //     path: '/setting-detail',
    //     name: 'settingDetail',
    //     component: () => import('../views/user/settingDetail.vue')
    // },
    // // Login / Register
    // {
    //     path: '/register',
    //     name: 'register',
    //     component: () => import('../views/user/register.vue')
    // },
    // {
    //     path: '/login',
    //     name: 'login',
    //     component: () => import('../views/user/login.vue')
    // }
]

const router = new VueRouter({
    routes
})

export default router
